/*
**  Copyright (c) 2014 Michael Liu(michael.liu.point@gmail.com).
**
**  Project: Gateway Unified Management Platform
**  File:    dbopt.h
**  Author:  Michael
**  Date:    03/20/2014
**
**  Purpose:
**    database operation defines.
*/

#ifndef __DB_OPT_H__
#define __DB_OPT_H__

#ifdef __cplusplus
extern "C" {
#endif				/* __cplusplus */

/* Include files. */

#include "common.h"
#include "cmrc.h"
#include "tavl.h"

/* Macro constant definitions. */

/* Type definitions. */

	typedef int record_cmp_func(void *record_a, void *record_b, void *cmp_param);

/* External function declarations. */

	extern int generate_unsigned_int_index_cmp(void *record_a, void *record_b, void *cmp_param);

	extern e_ret db_table_init(TAVL_treeptr * table_pp, record_cmp_func compare, void *param);
	extern e_ret db_table_add_record(TAVL_treeptr table_p, void *record, unsigned int size);
	extern e_ret db_table_del_record(TAVL_treeptr table_p, void *record_p);
	extern e_ret db_table_search_record(TAVL_treeptr table_p, void *record_p, unsigned int size);
	extern e_ret db_table_update_record(TAVL_treeptr table_p, void *record_p, unsigned int size);
	extern e_ret db_table_first_record(TAVL_treeptr table_p, void *record_p, unsigned int size);
	extern e_ret db_table_next_record(TAVL_treeptr table_p, void *record_p, unsigned int size);
	extern e_ret db_table_clean(TAVL_treeptr table_p);
	extern int db_table_record_counter(TAVL_treeptr table_p);

/* Macro API definitions. */

/* Global variable declarations. */

#ifdef __cplusplus
}				/* extern "C" */
#endif				/* __cplusplus */
#endif				/* __DB_OPT_H__ */
